package com.sun.hunk.hibernate.domain.impl;

import com.sun.hunk.hibernate.domain.CodeType;
import com.sun.hunk.hibernate.domain.GenericCode;
import com.sun.hunk.hibernate.domain.GenericCodeLabel;
import java.util.Set;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

/**
 *
 * @author sunil
 */
@Entity
@Table(name = "code_type")
public class CodeTypeImpl implements CodeType {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "id")
    private Long id;
    @Basic(optional = false)
    @Column(name = "description")
    private String description;
    @OneToMany(mappedBy = "codeType",targetEntity=GenericCodeImpl.class)
    private Set<GenericCode> genericCodeSet;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "codeType",targetEntity=GenericCodeLabelImpl.class)
    private Set<GenericCodeLabel> genericCodeLabelSet;

    public CodeTypeImpl() {
    }

    public CodeTypeImpl(Long id) {
        this.id = id;
    }

    public CodeTypeImpl(Long id, String description) {
        this.id = id;
        this.description = description;
    }

    public Long getId() {
        return id;
    }

    public void setId(Long id) {
        this.id = id;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public Set<GenericCode> getGenericCodeSet() {
        return genericCodeSet;
    }

    public void setGenericCodeSet(Set<GenericCode> genericCodeSet) {
        this.genericCodeSet = genericCodeSet;
    }

    public Set<GenericCodeLabel> getGenericCodeLabelSet() {
        return genericCodeLabelSet;
    }

    public void setGenericCodeLabelSet(Set<GenericCodeLabel> genericCodeLabelSet) {
        this.genericCodeLabelSet = genericCodeLabelSet;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (id != null ? id.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof CodeTypeImpl)) {
            return false;
        }
        CodeTypeImpl other = (CodeTypeImpl) object;
        if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "com.sun.hunk.hibernate.domain.CodeType[id=" + id + "]";
    }

}
